{% extends "emp_base.html" %}
{% block head %}<title>员工列表</title>{% endblock %}
{% block body %}

    <div class="container">
    <div style="float: right; width: 300px">
        <form method="get">
            <div class="input-group">
                <label for="search"></label>
                <input type="text" id="search" name="search" value="{{ search }}" class="form-control" placeholder="请输入员工姓名 支持模糊查询">
                <span class="input-group-btn">
                    <button class="btn btn-default" type="submit">
                        <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                    </button>
                </span>
            </div>
        </form>
    </div>
    <div style="margin-bottom: 10px">
        <a class="btn btn-success" href="/emp_add/" target="_blank">
            <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
            添加员工
        </a>
    </div>
    <div class="panel panel-default">
            <div class="panel-heading">
                <span class="glyphicon glyphicon-th" aria-hidden="true"></span>
                员工列表
            </div>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>员工ID</th>
                    <th>员工名称</th>
                    <th>员工年龄</th>
                    <th>账户余额</th>
                    <th>入职时间</th>
                    <th>所属部门</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for emp in emp_list %}
                <tr>
                    <td>{{ emp.id }}</td>
                    <td>{{ emp.name }}</td>
                    <td>{{ emp.age }}</td>
                    <td>{{ emp.account }}</td>
                    <td>{{ emp.entry_date }}</td>
                    <td>{{ emp.dept }}</td>
                    <td>
                        <a class="btn btn-primary btn-xs" href="/emp_update?upd_id={{ emp.id }}">编辑</a>
                        <a class="btn btn-danger btn-xs" href="/emp?del_id={{ emp.id }}&search={{ search }}">删除</a>
                    </td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

    <!-- bootstrap 分页 -->
    <ul class="pagination">
        <li><a href="?page=1" aria-label="Previous"><span aria-hidden="true">«</span></a></li>
        <li><a href="?page={{ last }}" aria-label="Previous"><span aria-hidden="true">/<</span></a></li>

        {% for page_num in page_range %}
            {% if page_num == curr_page %}
                <li class="active"><a href="?page={{ page_num }}">{{ page_num }}</a></li>
            {% else %}
                <li><a href="?page={{ page_num }}">{{ page_num }}</a></li>
            {% endif %}

        {% endfor %}
        <li><a href="?page={{ next }}" aria-label="Next"><span aria-hidden="true">/></span></a></li>
        <li><a href="?page={{ page_sum }}" aria-label="Next"><span aria-hidden="true">»</span></a></li>
    </ul>
</div>
{% endblock %}